$(document).ready(function () {
    fpxx.onload();
})
var fpxx = (function () {
	var init = function () {
    	layui.use('form', function(){
			  var form = layui.form
		});
    }
    return {
        onload : function () {
        	init();
            fpxx.tableDataFp();
            fpxx.dateShow();
            fpxx.fpxxAlert();
        },
     tableDataFp: function() {//发票信息表格
 		var data = [{
 				"number": "1",
 				"kpDate": "2018-07-01",
 				"fpdm": "3333232323",
 				"fpNumber":"12345678",
 				"gfsh":"410104712644904",
 				"gfName":"购方1",
 				"jebhs":"1,000.00",
 				"sl":"3%",
 				"se":"30.00",
 				"jshj":"1,030.00",
 				"fpzt":"正数发票",
 				"fplx":"增值税专用发票",
 				"operation":null
 			},
 			{
 				"number": "2",
 				"kpDate": "2018-07-01",
 				"fpdm": "3333232323",
 				"fpNumber":"12345678",
 				"gfsh":"410104712644904",
 				"gfName":"购方1",
 				"jebhs":"1,000.00",
 				"sl":"3%",
 				"se":"30.00",
 				"jshj":"1,030.00",
 				"fpzt":"正数发票",
 				"fplx":"机动车统一销售发票",
 				"operation":null
 			}
 		
 		];
 		$('#wepFpxx').DataTable({
 			"data": data,//javascript数据源配置
 			"columnDefs": [
 				{
 					"targets": -1,
 					"data": null,
 					"render": function(data, type, full, meta) {
 						return '<a href="#"><span class="wep_fpxx_alertbtn btn wxl_bg_lan1">查看</span></a>'
 					}
 				}
 			],
 			"columns": [
 			    {
 					"data": "number"
 				},
 				{
 					"data": "kpDate"
 				},
 				{
 					"data": "fpdm"
 				},
 				{
 					"data": "fpNumber"
 				},
 				{
 					"data": "gfsh"
 				},
 				{
 					"data": "gfName"
 				},
 				{
 					"data": "jebhs"
 				},
 				{
 					"data": "sl"
 				},
 				{
 					"data": "se"
 				},
 				{
 					"data": "jshj"
 				},
 				{
 					"data": "fpzt"
 				},
 				{
 					"data": "fplx"
 				},
 				{
 					"data": "operation"
 				}
 			],
// 			"paging": false, //分页
 			"info": false,
 			"ordering": false,
 			"lengthChange": false,
 			"searching": false,
 			"scrollX":true
 		});
     },
     /*日期显示*/
        dateShow:function(){
        	layui.use('laydate', function(){
			  var laydate = layui.laydate;
			  function dateObj(dom1,dom2){//结束时间不小于开始时间
					var startDate   = laydate.render({
						elem: dom1,
						done:function(value,date){
							if( value !== '' ){
								endDate.config.min.year = date.year;
								endDate.config.min.month = date.month - 1;
								endDate.config.min.date = date.date;
							}else{
								endDate.config.min.year = '';
								endDate.config.min.month = '';
								endDate.config.min.date = '';
							}
						}
					});
					var endDate  = laydate.render({
						elem: dom2,
						done:function(value,date){
							if( value !== '' ){
								startDate.config.max.year = date.year;
								startDate.config.max.month = date.month - 1;
								startDate.config.max.date = date.date;
							}else{
								startDate.config.max.year = '';
								startDate.config.max.month = '';
								startDate.config.max.date = '';
							}
						}
					});
				}
				dateObj('#wep_date1','#wep_date2');
			})
       },
       /*点击操作弹出框*/
	    fpxxAlert:function(){
	    	$(document).on('click','.wep_fpxx_alertbtn',function(){
	    		if($(this).parents('td').prev().text() == "增值税专用发票"){
	    			parent.cxzx.alertBox2('增值税专用发票','.wep_fpxx_alert','.zzs_box','.jdc_box')
	    		}else{
	    			parent.cxzx.alertBox2('机动车统一销售发票','.wep_fpxx_alert','.jdc_box','.zzs_box')
	    		}
	    	})
	    }
    }
})();